package com.zhx.learn.rabbitmq.message;

import org.springframework.amqp.rabbit.annotation.Exchange;
import org.springframework.amqp.rabbit.annotation.Queue;
import org.springframework.amqp.rabbit.annotation.QueueBinding;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

/**
 * describe: mq接受
 *
 * @author zhanghaixuan
 * @date 2018/09/05
 **/
@Component
public class MqRecevier {

    //1.已经有队列的情况下
    // @RabbitListener(queues = "myQueue")
    //2.自动创建队列
    //@RabbitListener(queuesToDeclare = @Queue("myQueue"))
    //3. 自动创建,并且 Exchange和Queue 绑定
    @RabbitListener(bindings = @QueueBinding(
            value = @Queue("myQueue"),
            exchange = @Exchange("myExchange")
    ))
    public void process(String message){
        System.out.println("MqRecevier:"+message);
    }
}
